#
# This file is a part of the open-eBackup project.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at
# http://mozilla.org/MPL/2.0/.
#
# Copyright (c) [2024] Huawei Technologies Co.,Ltd.
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#

from abc import ABCMeta, abstractmethod

from common.common_models import ActionResult
from gaussdbt.single.comm.utils.gst_single_comm_utils import GstSingleCommonUtil


class GstResourceBase(metaclass=ABCMeta):
    """gaussdbt资源注册执行基类
    """
    def __init__(self, pid, param_dict):
        self.pid = pid
        self.param_dict = param_dict

    def exec_check_application(self):
        """资源应用检查"""
        pass

    def exec_list_application_resource(self):
        """资源列举"""
        pass

    def exec_query_cluster(self):
        """资源查询"""
        pass

    def output_action_result(self, action_ret: ActionResult):
        """输出任务结果到结果文件"""
        GstSingleCommonUtil.output_action_result(
            self.pid, action_ret.code, body_err=action_ret.body_err, body_err_params=action_ret.body_err_params,
            message=action_ret.message)
